class Solution {
public:
    void setZeroes(vector<vector<int>>& matrix)
    {
        int m = matrix.size(), n = matrix[0].size();
        vector<pair<int, int>> ret;
        for (int i = 0; i < m; i++)
        {
            for (int j = 0; j < n; j++)
            {
                if (matrix[i][j] == 0)
                {
                    ret.push_back({ i,j });
                }
            }
        }

        for (int i = 0; i < ret.size(); i++)
        {
            auto [a, b] = ret[i];
            for (int j = 0; j < n; j++)
            {
                matrix[a][j] = 0;
            }
            for (int k = 0; k < m; k++)
            {
                matrix[k][b] = 0;
            }
        }
    }
};